package com.neusoft.hifly.push.mobile.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.hifly.core.pojo.ApiCode;
import com.neusoft.hifly.core.pojo.ApiResponse;
import com.neusoft.hifly.push.mobile.domain.JPushModelObj;
import com.neusoft.hifly.push.mobile.server.IJPushService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * Title: 消息推送中间件
 * <p>
 * Description: 站内信 API接口
 * <p>
 * Copyright: 2019
 * <p>
 * Company: 东软汉枫
 *
 * @author lh_neu
 * @version 1.0.0
 */
@CrossOrigin
@RestController
@RequestMapping("/api/v1/push/mobile")
@Api(value = "push-mobile-api", description = "Mobile推送接口")
public class PushMobileApi {
	@Autowired(required = false)
	private IJPushService jPushService;

	/**
	 * 根据传入的json字符串来判断实现什么方式的推送通知内容为 ALERT
	 *
	 * @param jPushModelObj
	 *            极光推送所用实体
	 * @return 集合
	 */
	@ApiOperation("查询站内消息集合")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "jPushModelObj", value = "极光推送所用实体", dataType = "JPushModelObj", required = true) })
	@PostMapping(value = "/sendMobilePushAlertFromJson")
	public ApiResponse<?> sendMobilePushAlertFromJson(final JPushModelObj jPushModelObj) {
		if (jPushModelObj == null) {
			return new ApiResponse<>(ApiCode.ERROR.getCode(), "参数错误!");
		}
		return new ApiResponse<>(ApiCode.SUCCESS.getCode(), "成功！",
				jPushService.sendMobilePushAlertFromJson(jPushModelObj));
	}
}
